package br.com.ia.struts.action;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import br.com.enovar.trex.core.model.BaseModel;
import br.com.enovar.trex.struts.action.TRexCRUDBaseAction;
import br.com.enovar.trex.struts.form.TRexBaseForm;
import br.com.ia.model.Empresa;
import br.com.ia.struts.form.EmpresaForm;

public class EmpresaAction extends TRexCRUDBaseAction{

	@Override
	public BaseModel copyProperties(TRexBaseForm form) {
		// TODO Auto-generated method stub
		EmpresaForm empresaForm = (EmpresaForm)form;
		Empresa empresa = new Empresa();
		
		empresa.setCodigo(empresaForm.getCodigo());
		empresa.setNome(empresaForm.getNome());
		empresa.setTelefone(empresaForm.getTelefone());
		
		return empresa;
	}

	@Override
	public void copyProperties(BaseModel model, TRexBaseForm form) {
		// TODO Auto-generated method stub
		EmpresaForm empresaForm = (EmpresaForm)form;
		Empresa empresa = (Empresa)model;
		
		empresaForm.setCodigo(empresa.getCodigo());
		empresaForm.setNome(empresa.getNome());
		empresaForm.setTelefone(empresa.getTelefone());
		
	}

	@Override
	public Serializable getId(TRexBaseForm form, HttpServletRequest request) {
		// TODO Auto-generated method stub
		
		EmpresaForm empresaForm = (EmpresaForm)form;
		
		return empresaForm.getCodigo();
	}

	
	

}
